/**
 *	\file AKCPPStateMaintainerAdapter.mm
 *  
 *  \section desc_sec Description
 *  Description
 *  
 *  \if copyright
 *  	Copyright 2008 Ben Chen. All rights reserved.
 *  \endif
 *  
 *  \section hist_sec Change History:
 *  	-	2/20/08		BC		Created this file
 *  
 *  <hr>
 *  \addtogroup AnimalKingdom
 *  @{
 */

#import "AKCPPStateMaintainerAdapter.h"
#import "AbstractClasses.h"
#import "AKCPPConvertors.h"

@implementation AKCPPStateMaintainerAdapter

- (id)initWithAKCPPStateMaintainer:(AKCPPStateMaintainer*)cppStateMaintainer {
	self = [super init];
	if (self) {
		model = cppStateMaintainer;
	}
	return self;
}

- (void)dealloc {
	delete model;
	[super dealloc];
}

- (void)backToInitialState {
	model->backToInitialState();
}

- (BOOL)performMove:(AKMove)newMove {
	return (model->performMove(newMove) == true ? YES : NO);
}

- (NSArray*)reachableCellsForPiece:(AKPiece)piece {
	return AKCellIndexArrayFromVector(model->getReachableCellsForPiece(piece));
}

- (NSArray*)newPiecesAtCell:(AKCellIndex)cell {
	return AKPieceArrayFromVector(model->getPlaceablePiecesAtCell(cell));
}

- (AKPiece)moveablePieceAtCell:(AKCellIndex)cell {
	return model->getMoveablePieceAtCell(cell);
}

- (NSArray*)eliminatedPieces {
	return AKPieceArrayFromVector(model->getElminatedPieces());
}

- (NSArray*)createdPieces {
	return AKPieceArrayFromVector(model->getCreatedPieces());
}

- (NSArray*)movedPieces {
	return AKMoveArrayFromVector(model->getMovedPieces());
}

- (AKSideIndex)nextPlayerSide {
	return model->getNextPlayerSide();
}

- (NSArray*)winners {
	return AKSideIndexArrayFromVector(model->getWinners());
}

@end

/** @} */
